package com.stark.wechat.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.stark.wechat.service.impl.JobQueueServiceImpl;
import com.stark.wechat.service.impl.PushTemplateMessageServiceImpl;

/**
 * 定时推送模板消息作业。
 * @author Ben
 * @since 1.0.0
 * @version 1.0.1, 2017/9/22
 */
@Component("pushTemplateMessageJob")
public class PushTemplateMessageJob {
	public static final String JOB_ID = "JOB_PUSH_TEMPLATE_MESSAGE";
	public static final String JOB_NAME = "定时推送模板消息作业";
	
	@Autowired
	private JobQueueServiceImpl jobQeueService;
	@Autowired
	private PushTemplateMessageServiceImpl pushTemplateMessageService;
	
	public void execute() {
		boolean isJobExcutorToday = this.jobQeueService.isJobExcutorToday(PushTemplateMessageJob.JOB_ID);
		if (isJobExcutorToday) {
			this.pushTemplateMessageService.pushRegularly();
		}
	}
}
